package 打家劫舍;

public class Solution2 {
    public int rob(int[] nums) {
        if (nums.length==0){
            return 0;
        }
        int len = nums.length;
        int pre = 0;
        int cur = 0;

        for(int i:nums){
           int temp = Math.max(cur,pre+i);
           pre = cur;
           cur = temp;
        }
        return cur;
    }
}
